package com.gym.demo;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
/**
 * 文件复制
 * @author admin
 *
 */
public class IOText1 {
	public static void main(String[] args) throws IOException {
		File file = new File("d:/Text");
		if(!file.exists()){
			file.mkdirs();
		}
		File file1 = new File("D:\\guan.txt");
		File file2 = new File("d:/Text/guan.txt");
		FileInputStream fileInputStream = new FileInputStream(file1);
		FileOutputStream fileOutputStream = new FileOutputStream(file2);
		byte[] bs = new byte[1024];
		int len = 0;
		//定义一个临时变量，实时接收长度，避免长度不够1024，复制空白区域
		while ((len=fileInputStream.read(bs))!=-1) {
			fileOutputStream.write(bs,0,len);
		}
		fileOutputStream.close();
		fileInputStream.close();
	}
}
